package org.leopard.demo.service;

import java.rmi.RemoteException;
import java.rmi.server.UnicastRemoteObject;
import java.util.ArrayList;
import java.util.List;

/**
 * @author IBM CHEN ZHI KAN
 * @create 2018/8/9
 */
public class UserServiceImpl extends UnicastRemoteObject implements  UserService{
  static List<User> users=new ArrayList<User>();
  static {
    User user=new User();
    user.setId("1");
    user.setAge("18");
    user.setName("a");
    User user2=new User();
    user.setId("1");
    user.setAge("18");
    user.setName("a");
    users.add(user);
    users.add(user2);
  }
  public UserServiceImpl() throws RemoteException {
    super();
  }
  public UserServiceImpl(User user) throws RemoteException {
    super();
  }

  public User getUser(String id) throws RemoteException {
    for(User user:users){
      if(user.getId().equals(id)){
        return user;
      }
    }
   throw new RuntimeException("不存在此用户");
  }
}
